import Toast from '@vant/weapp/toast/toast';
import Ajax from "../../../../utils/ajax"
import Util from "../../../../utils/util"
const app = getApp();
Component({
  options:{ styleIsolation : 'shared'},
  /**
   * 组件的属性列表
   */
  properties: {

  },

  /**
   * 组件的初始数据
   */
  data: {
    fileList1:[],
    fileList2:[],
    propertyAddress:'',
    radio:'1',  
    ztLocation:{},
  },
  attached(){
    console.log("组件进入时渲染", app.globalData.ztLocation  );
     this.setData({ ztLocation: app.globalData.ztLocation, propertyAddress:app.globalData.ztLocation.propertyAddress   });
  },
  afterRead(f){

  },
 
  /**
   * 组件的方法列表
   */
  methods: {
    onChange(e){ 
      this.setData({ radio:e.detail })
      console.log(e.detail);
      app.globalData.ztLocation.certificateType = e.detail 
   },
   onChangeAddress(e){
    this.setData({ propertyAddress:e.detail.value })
    console.log(e.detail);
    app.globalData.ztLocation.propertyAddress = e.detail.value 
   },
   afterRead(e){  
    var th = this; 
    var id = e.currentTarget.dataset.id // user id1 id2 code1 code2  company
    Ajax.upload(event.detail.file,1,{
      success:function(data){
        console.log("上传后的响应",data);
        var arr = [    { url: data.data.url} ]
        if(id=='img1'){
          th.setData({ fileList1: arr })
          app.globalData.ztLocation.certificatePath = data.data.url
        } 
        if(id=='img2'){
          th.setData({ fileList2: arr }) 
          app.globalData.ztLocation.planPath = data.data.url
        } 
      },
    } ) 
   },
  }
})
